
#include <Side.h>
#include <math.h>

namespace{

double getFixDecimal(double value)
{
	return (floor(value*pow(10, 2))/pow(10, 2));
}

bool isBigger(double value1, double value2)
{
	return ((value1 - value2) > 0);
}

}

Side::Side(double size, double minSize, double maxSize, bool maxSizeValid):
	size_m(getFixDecimal(size)),
	minSize_m(minSize),
	maxSize_m(maxSize),
	maxSizeValid_m(maxSizeValid)
{
}

bool Side::isSizeValid() const
{
	return (isBigger(size_m, minSize_m) && 
		(maxSizeValid_m ? !isBigger(size_m, maxSize_m) : isBigger(maxSize_m, size_m)));
}

double Side::getSize() const
{
	return size_m;
}

void Side::setSize(double size)
{
	size_m = getFixDecimal(size);
}
